package com.ruoyi.web.controller.business;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.HuoPinPriceHis;
import com.ruoyi.system.service.IHuoPinPriceHisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author qbf
 * 货品价格历史
 */
@RequestMapping("/system/huoPinPriceHis")
public class HuoPinPriceHisController {

    @Resource
    private IHuoPinPriceHisService priceHisService;

    @PostMapping("/add")
    public AjaxResult add(HuoPinPriceHis his){
        boolean ok = priceHisService.save(his);
        if(ok){
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
    }

    @GetMapping("/hist")
    public AjaxResult selectHis(@RequestParam(value = "huoPinId") Long huoPinId){
        List<HuoPinPriceHis> hisList = priceHisService.selectHisList(huoPinId);
        return AjaxResult.success(hisList);
    }
}
